import java.util.Arrays;
import java.util.Comparator;

public class StuCompartor  {

    String name;
    int age;

    public StuCompartor() {
    }

    public StuCompartor(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "StuCompartor{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public static void main(String[] args) {

        Student[] students = new Student[2];
        students[0] = new Student("zhangsan", 32);
        students[1] = new Student("lisi", 52);
        AgeComparator ageComparator = new AgeComparator();
        Arrays.sort(students, ageComparator);
        System.out.println(Arrays.toString(students));

        NameComparator nameComparator = new NameComparator();
        Arrays.sort(students, nameComparator);
        System.out.println(Arrays.toString(students));
    }
}
